Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
jest-matcher-utils
Advanced tools
The jest-matcher-utils package provides utility functions for creating custom Jest matchers. It is designed to help developers write their own matchers that integrate seamlessly with Jest's built-in expectation system, offering a way to extend Jest's assertion capabilities with custom logic. The utilities provided by this package include formatting values for error messages, comparing values, and generating matcher error messages.
pretty-format
Formats any JavaScript value for pretty printing, which is useful for generating readable error messages in custom matchers.
const { prettyFormat } = require('jest-matcher-utils');
console.log(prettyFormat({ foo: 'bar' }));
matcherHint
Generates a hint string for a matcher, which can be used at the beginning of error messages to indicate which matcher failed.
const { matcherHint } = require('jest-matcher-utils');
console.log(matcherHint('.toBe'));
printExpected and printReceived
These functions format the expected and received values to be included in error messages, applying color highlighting to improve readability.
const { printExpected, printReceived } = require('jest-matcher-utils');
console.log(`Expected: ${printExpected(true)}
Received: ${printReceived(false)}`);
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. It offers similar functionality to jest-matcher-utils in the sense that it provides a rich set of assertions and plugins to extend its capabilities. However, Chai is a standalone assertion library, not tied to any specific test runner like Jest.
Expect is a minimalist assertion library that comes with Jest but can also be used independently. It provides a similar API for writing test assertions as jest-matcher-utils, but jest-matcher-utils focuses more on the utilities for creating custom matchers rather than providing a comprehensive set of built-in matchers.
jest 16.0.0
jest <pattern>
is now case-insensitive.it.only
, it.skip
, test.only
, test.skip
and xtest
.--testNamePattern=pattern
or -t <pattern>
to run individual tests in test files.a
, o
, p
, q
or enter
while tests are running in the watch mode, the test run will be interrupted.--bail
now works together with --watch
.test.concurrent
for concurrent async tests..jsx
extension.jest.clearAllMocks
to clear all mocks manually.jest-snapshot
can now be more easily integrated into other test runners and used in other projects.fit
or when an error is thrown in a test.toHaveBeenLastCalledWith
, toHaveBeenCalledWith
, lastCalledWith
and toBeCalledWith
failure messages.toBeInstanceOf
matcher.toContainEqual
matcher.toThrowErrorMatchingSnapshot
matcher.moduleNameMapper
resolution.setupTestFrameworkScriptFile
script to make it easier to use chai together with Jest.--findRelatedTests <fileA> <fileB>
cli option to run tests related to the specified files.jest.deepUnmock
to babel-plugin-jest-hoist
.jest.runTimersToTime
which is useful together with fake timers.FAQs
A set of utility functions for expect and related packages
The npm package jest-matcher-utils receives a total of 37,711,824 weekly downloads. As such, jest-matcher-utils popularity was classified as popular.
We found that jest-matcher-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.